<template>
  <div>
    <span v-for="item in userlist">
        会员名称：{{item.usrename}}<br/>
        会员等级 <span v-if="item.vip == 0">普通用户</span>
        <span v-if="item.vip==1">会员</span><br/>
      <button @click="shenji(item.id)">升级为VIP</button><br/>

    </span>
  </div>
<!--  <table>-->

<!--    <tr>-->
<!--      <th>会员名称</th>-->
<!--      <th>会员等级</th>-->
<!--    </tr>-->
<!--    <tr v-for="item in userlist">-->
<!--      <td>{{item.usrename}}</td>-->
<!--&lt;!&ndash;      <td v-if="item.vip==0">普通用户</td>&ndash;&gt;-->
<!--&lt;!&ndash;      <td v-if="item.vip==1">会员用户</td>&ndash;&gt;-->
<!--      <button @click="shenji(item.id)">升级为VIP</button>-->
<!--    </tr>-->
<!--  </table>-->
</template>

<script>
  import axios from 'axios'
    export default {
        name: "User",
      data(){
          return{
            userlist:[]
          }
      },
      mounted() {
          axios({
            url:'http://127.0.0.1:8000/user/',
            method:'post',

          }).then(res=>{
            this.userlist = res.data.data

          })
      },
      methods:{
          shenji(i){
            console.log(i)
            let from_data = new FormData();
            from_data.append('uid',i)
            axios({
              url:'http://127.0.0.1:8000/vip/',
              method: 'post',
              data:from_data

            }).then(res=>{
              alert('升级成功')
            })
          }

      }
    }
</script>

<style scoped>

</style>
